-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract getContributionBalance function, use that rather than wrapper… #13151
Conversation
(Standard links)
|
1a5edba
to
238c918
Compare
… function from Contribution Main class
238c918
to
26085ea
Compare
AND ft.status_id IN ({$statusId}, {$refundStatusId}) | ||
"; | ||
|
||
$ftTotalAmt = CRM_Core_DAO::singleValueQuery($sqlFtTotalAmt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can further optimize it via:
$ftTotalAmt = CRM_Core_BAO_FinancialTrxn::getTotalPayments($contributionId);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@monishdeb ok - wanna do that as a follow up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@monishdeb I just revisited this to see if I should make this suggested change in this PR (now it's Monday :-))
But there is a minor change between this and the function you suggest calling - this function looks at completed & refunded whereas that one only looks at completed.
The getTotalPayments function is called from 2 places & my feeling is that those places would be better served by also looking at refunds - per this - but I think we should analyse that so a follow up PR makes more sense. I think @jitendrapurohit had actually suggested changing one of those places in his recent PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Submitted followup PR #13187
@monishdeb can we merge this? |
@@ -494,9 +478,6 @@ public static function getPartialPaymentWithType($entityId, $entityName = 'parti | |||
elseif ($paymentVal > 0) { | |||
$value['amount_owed'] = $paymentVal; | |||
} | |||
elseif ($lineItemTotal == $ftTotalAmt) { | |||
$value['full_paid'] = $ftTotalAmt; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol and I didn't relaised it's not used anwhere in Civi but still we are having a separate attribute.
$ grep -irn "full_paid" CRM/
CRM//Core/BAO/FinancialTrxn.php:498: $value['full_paid'] = $ftTotalAmt;
Agree with this change
@@ -207,16 +207,15 @@ public function testAddPartialPayment() { | |||
$amtPaid = 60; | |||
$balance = $feeAmt - $amtPaid; | |||
$result = $this->addParticipantWithPayment($feeAmt, $amtPaid); | |||
extract($result); | |||
$paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($participant['id'], 'event'); | |||
$paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($result['participant']['id'], 'event'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better :)
Overview
Minor code cleanup to extract the guts of an overloaded function so just the relevant part can be called. These are internal functions only.
Before
Complex function
function getPartialPaymentWithType
doing multiple thingsAfter
Get balance part callable by itself
Technical Details
@monishdeb @pradpnayak this function is only called from a few places and I couldn't find any evidence that the 'full_paid' parameter is ever used so I dropped that. I feel like this 'getByType' stuff is a bit silly & we should determine that before calling it but for now I haven't touched that.
I also updated the payment only bit from the contribution form to call this function - this came off trying to understand https://github.com/civicrm/civicrm-core/pull/12319/files#diff-e59ea24da123edeec35a0c498d02874fR1322 & feeling that we just need to know the amount owing whatever the status
Comments